import React, { ReactElement, ReactNode } from 'react'
import { useAuth } from '@/hooks'
import { Redirect } from 'umi'

interface Props {
    children?: ReactNode
}

export default function auth({ children }: Props): ReactElement {
    const { isLogin } = useAuth()
    console.log('我准备拦截了', isLogin)
    if (isLogin) {
        return (
            <div>
                { children }
            </div>
        )
    } else {
        return (
            <Redirect to="/login"/>
        )
    }
    
}
